#include "Mouse.h"

namespace core
{

Vector<IMouseListener*> Mouse::_listeners;

void Mouse::OnPressButton( MouseButton button )
{
	for( IteratorPtr<IMouseListener*> listeners( _listeners.GetIterator( ) );
			!listeners->IsEnd( );
			listeners->Next( ) )
	{
		listeners->Current( )->ButtonPressed( button );
	}
}

void Mouse::OnReleaseButton( MouseButton button )
{
	for( IteratorPtr<IMouseListener*> listeners( _listeners.GetIterator( ) );
			!listeners->IsEnd( );
			listeners->Next( ) )
	{
		listeners->Current( )->ButtonReleased( button );
	}
}

void Mouse::OnMoveCursor( Vec2 pos )
{
	for( IteratorPtr<IMouseListener*> listeners( _listeners.GetIterator( ) );
			!listeners->IsEnd( );
			listeners->Next( ) )
	{
		listeners->Current( )->OnMove( pos );
	}
}

void Mouse::OnMoveWheel( int pos )
{
	for( IteratorPtr<IMouseListener*> listeners( _listeners.GetIterator( ) );
			!listeners->IsEnd( );
			listeners->Next( ) )
	{
		listeners->Current( )->OnWheel( pos );
	}
}

void Mouse::AddListener( IMouseListener* listener )
{
	_listeners.Add( listener );
}

void Mouse::RemoveListener( IMouseListener* listener )
{
	_listeners.Remove( listener );
}
}
